import { Scene, PolygonLayer, LineLayer, PointLayer, ILayer } from "@antv/l7";
import { Map } from "@antv/l7-maps";
import data from "@/assets/cangxian";
const sub = [{
    name: '杜生镇',
    longitude: 116.554284,
    latitude: 38.380225
}, {
    name: '崔尔庄镇',
    longitude: 116.554036, latitude: 38.279892
}, {
    name: '高川乡',
    longitude: 116.556595, latitude: 38.2409
}, {
    name: '大官厅乡',
    longitude: 116.632798, latitude: 38.373282
}, {
    name: '大褚村回族乡',
    longitude: 116.678924, latitude: 38.273415
}, {
    name: '黄递铺乡',
    longitude: 116.672967, latitude: 38.233676
}, {
    name: '杜林镇',
    longitude: 116.743894, latitude: 38.337044
}, {
    name: '纸房头乡',
    longitude: 116.755826, latitude: 38.273291
}, {
    name: '捷地回族乡',
    longitude: 116.864317, latitude: 38.243223
}, {
    name: '张官屯镇',
    longitude: 116.821718, latitude: 38.199407
}, {
    name: '兴济镇',
    longitude: 116.901144, latitude: 38.467664
}, {
    name: '薛官屯乡',
    longitude: 116.974716, latitude: 38.425908
}, {
    name: '姚官屯镇',
    longitude: 116.905052, latitude: 38.372877
}, {
    name: '李天木镇',
    longitude: 117.050885, latitude: 38.333837
}, {
    name: '风化店乡',
    longitude: 116.985628, latitude: 38.281088
}, {
    name: '旧州镇',
    longitude: 117.033261, latitude: 38.207965
}, {
    name: '仵龙堂乡',
    longitude: 117.083681, latitude: 38.166097
}, {
    name: '刘家庙乡',
    longitude: 116.975928, latitude: 38.120654
}, {
    name: '汪家铺镇',
    longitude: 116.941494, latitude: 38.258285
}]
export class Box11 {
    scene: Scene;
    joinedLayer?: ILayer;
    constructor() {
        this.scene = new Scene({
            id: "box11",
            map: new Map({
                center: [116.830315, 38.281784],
                zoom: 9.4,
                style: "normal"
            }),
            logoVisible: false,
        });
        this.scene.setMapStatus({
            dragEnable: false,
            doubleClickZoom: false,
            zoomEnable: false
        });
        this.scene.on("loaded", () => {
            const joinedLayer = new PointLayer({
                zIndex: 6,
            })
                .source(sub, {
                    parser: {
                        type: "json",
                        x: "longitude",
                        y: "latitude",
                    },
                })
                .shape("name", "text")
                .size(14)
                .color("#3575ca");
            const filllayer = new PolygonLayer({
                name: "fill",
            })
                .source(data)
                .shape("fill")
                .color("#59689b");
            const linelayer = new LineLayer({
                zIndex: 1,
                name: "line",
            })
                .source(data)
                .shape("line")
                .size(0.5)
                .color("#fff")
                .style({
                    opacity: 0.5,
                });
            this.scene.addLayer(joinedLayer);
            this.scene.addLayer(filllayer);
            this.scene.addLayer(linelayer);
        });
    }
    setDate(joined: any) {
        if (this.joinedLayer) {
            this.scene.removeLayer(this.joinedLayer)
        }
        this.joinedLayer = new PointLayer({
            zIndex: 6,
        })
            .source(joined, {
                parser: {
                    type: "json",
                    x: "longitude",
                    y: "latitude",
                },
            })
            .shape("simple")
            .size(4)
            .color("#37a5ee");
        this.joinedLayer
        this.scene.addLayer(this.joinedLayer);
    }
}
